import { Card, Tree } from 'antd';
import React from 'react';
import styles from './index.less';

const initData = [
  {
    title: 'Word',
    key: 'word',
    isLeaf: true,
  },
  {
    title: 'Excel',
    key: 'excel',
    isLeaf: true,
  },
  {
    title: 'PPT',
    key: 'ppt',
    isLeaf: true,
  },
];

const { DirectoryTree } = Tree;

const TypeTree = (props) => {
  const { onNodeSelect } = props;

  const onSelect = (selectedKeys) => {
    if (onNodeSelect) {
      onNodeSelect(selectedKeys[0]);
    }
  };

  return (
    <Card
      title="类型"
      size="small"
      bordered={false}
      className={styles.sidebar}
      style={{ width: 300 }}
    >
      <DirectoryTree treeData={initData} onSelect={onSelect} />
    </Card>
  );
};

export default TypeTree;
